package com.bupt.godxian.charging.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bupt.godxian.charging.entity.WaitQueue;
import org.apache.ibatis.annotations.*;

@Mapper
public interface WaitQueueMapper extends BaseMapper<WaitQueue> {
    @Insert("INSERT INTO wait_queue(type, state, charge_id) VALUES(#{type}, #{state}, #{chargeId})")
    int insert(@Param("type") String chargeMode, @Param("chargeId") String chargeId,@Param("state") int state);
    //    @Options(useGeneratedKeys = true, keyProperty = "id")

    @Select("SELECT * FROM wait_queue WHERE id = #{id}")
    WaitQueue selectByPrimaryKey(Long id);

    // 添加其他需要的数据库操作方法

    @Select("SELECT COUNT(*) FROM wait_queue WHERE state = #{state}")
    int getWaitQueueCount(@Param("state") int state);

    @Update("UPDATE wait_queue SET state = 1, charge_id = #{chargeId} WHERE type = #{chargeMode}")
    void addWaitQueue(@Param("chargeMode") String chargeMode, @Param("chargeId") String chargeId);

    @Delete("delete from wait_queue where charge_id=#{charge_id}")
    void deleteById(String charge_id);
}
